#include "LocalIni.h"

LocalIni::LocalIni()
{
}

bool LocalIni::parser()
{
    if(!this->check())
    {
        return false;
    }

    QSettings ini(m_path, QSettings::IniFormat);
    ini.setIniCodec("UTF-8");

    quint8 mode = ini.value("mode").toInt();
    QString ip = ini.value("ip").toString();
    QString mask = ini.value("mask").toString();
    QString gateway = ini.value("gateway").toString();

    m_netParam.setMode(mode);
    m_netParam.setIp(ip);
    m_netParam.setMask(mask);
    m_netParam.setGateway(gateway);

    return true;
}



void LocalIni::clear()
{

}

bool LocalIni::modif(const NetParam &netParam)
{
    if(!this->check())
    {
        return false;
    }
    m_netParam = netParam;
    QSettings ini(m_path, QSettings::IniFormat);
    ini.setIniCodec("UTF-8");

    ini.setValue("mode",m_netParam.mode());
    ini.setValue("ip", m_netParam.ip());
    ini.setValue("mask",m_netParam.mask());
    ini.setValue("gateway",m_netParam.gateway());

    return true;
}



NetParam LocalIni::netParam() const
{
    return m_netParam;
}


